<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('发货明细报表')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">

                    <div class="layui-inline">
                        <label class="layui-form-label">发运时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="fpsj_start" id="stime"
                                   placeholder="yyyy-MM-dd HH:mm:ss"/>
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-normal" >重置</button>
                    </div>
                </form>
                <div class="group-button tpl-button" id="toolbar">

                    <a class="layui-btn layui-btn-sm layui-btn-normal out-put">
                        <i class="layui-icon">&#x1005;</i> 导出
                    </a>
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"  class="table text-nowrap" ></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script th:inline="javascript">
    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                /*这里激活状态那个按钮用不到，啥都不需要写，只读*/
            }
        }

        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;

        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function () {
                    zzpUtils.refreshTable("#table");
                },
                //导出
                exportEvent: function (data) {
                    var arr = [];
                    var $rows = $table.bootstrapTable('getSelections');
                    if ($rows.length > 0) {
                        arr = $.map($rows, function (row) {
                            return row.id;
                        })
                    }
                    /*
                     * 以下是将ids和对象拼接在一起
                     * */
                    var str = zzpUtils.getFormJson($("#searchForm"));
                    var object2 = Object.assign({ids: arr}, str);
                    /*将条件查询和ids传到后台*/
                    zzpUtils.outputXslx({
                        url: "/WmsDeliveryDetailsController/ShippingdetailsExcel",
                        data: JSON.stringify(object2)
                    });
                }
            }
        });

        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff'
            , range: '~'//练起来
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
                url: '/WmsDeliveryDetailsController/Shippingdetails',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'ordernumber',
                title: '订单号'
            }, {
                field: 'thedateofissuance',
                title: '发货日期',
                formatter: function (value, row, index) {
                    var sj='';
                    if(value!=null&&value!=''){
                        sj=value.substring(0,19);
                    }
                    return sj;
                }
            }, {
                field: 'dateofpayment',
                title: '支付日期',
                width:150,
                formatter: function (value, row, index) {
                    var sj='';
                    if(value!=null&&value!=''){
                        sj=value.substring(0,19);
                    }
                    return sj;
                }
            }, {
                field: 'classA',
                title: '一级'
            }, {
                field: 'classB',
                title: '二级'
            }, {
                field: 'classC',
                title: '三级'
            }, {
                field: 'purpose',
                title: '订单类型'
            }, {
                field: 'initiator',
                title: '发起人'
            }, {
                field: 'initiatingDepartment',
                title: '发起部门'
            }, {
                field: 'orderstatus',
                title: '订单状态'
            }, {
                field: 'consigneeName',
                title: '收货人姓名'
            }, {
                field: 'country',
                title: '国家'
            }, {
                field: 'sheng',
                title: '省份'
            }, {
                field: 'city',
                title: '城市'
            }, {
                field: 'county',
                title: '县'
            }, {
                field: 'receivingaddress',
                title: '收货地址'
            }, {
                field: 'wayofreceiving',
                title: '收货方式'
            }, {
                field: 'telephone',
                title: '电话'
            }, {
                field: 'productnumber',
                title: '产品编号'
            }, {
                field: 'productname',
                title: '产品名称'
            }, {
                field: 'quantity',
                title: '数量'
            }, {
                field: 'totalamount',
                title: '总金额'
            }, {
                field: 'ordernotes',
                title: '订单备注'
            }
            ],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });

      /*  //查询
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })*/

        /*顶部按钮导出 */
    /*    $(".out-put").on('click', function () {
            var arr = [];
            var $rows = $table.bootstrapTable('getSelections');
            if ($rows.length > 0) {
                arr = $.map($rows, function (row) {
                    return row.id;
                })
            }
            var xhr = new XMLHttpRequest();
            xhr.open("POST", "http://localhost:8080/zxsdwms/WmsDeliveryDetailsController/ShippingdetailsExcel", true);
            xhr.responseType = "blob";
            xhr.setRequestHeader('Accept', 'application/json');
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.setRequestHeader('Charset', 'utf-8');
            xhr.onload = function () {
                if (this.status == 200) {
                    var name = xhr.getResponseHeader("Content-disposition");
                    name = decodeURI(name);
                    var filename = name.substring(20, name.length);
                    var blob = new Blob([xhr.response], {type: 'text/xls'});
                    var csvUrl = URL.createObjectURL(blob);
                    var link = document.createElement('a');
                    link.href = csvUrl;
                    link.download = filename;
                    link.click();
                }
            };
            /!*
            * 以下是将ids和对象拼接在一起
            * *!/
            var str = zzpUtils.getFormJson($("#searchForm"));
            var object2 = Object.assign({ids: arr}, str);
            /!*将条件查询和ids传到后台*!/
            xhr.send(JSON.stringify(
                object2
            ));
        })//导出结束
*/
    });

</script>
</html>